home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / apl / apltex_.com / RSB.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-06-03  |  3.8 KB  |  116 lines

  1. ; RSB.ASM
  2. ; RSB - ASM fn to call C RSB (Read Screen Block) fn
  3.  
  4.  
  5. include $rap.mac
  6.  
  7.          DOSSEG                 ; std segment conventions
  8.          .MODEL    SMALL        ; Small memory model
  9.  
  10.  
  11.          .CODE                  ; code segment
  12.          EXTRN     _rsb:NEAR
  13.  
  14. SROW     DW        0
  15. SCOL     DW        0
  16. NROWS    DW        0
  17. NCOLS    DW        0
  18. NELEM    DW        0
  19. NPARS    DW        0
  20. NBYTES   DW        0
  21. APLCS    DW        0
  22.  
  23.          PUBLIC _main
  24. _main    PROC
  25.          int    3
  26.          push   bp
  27.          mov    bp,sp
  28.  
  29.          push      ds
  30.          push      es
  31.          push      di
  32.          push      si
  33.  
  34.          ; get right arg (location,size info) ... load to vars
  35.          mov       ax,cs                ; prepare to get var ptr
  36.          sub       ax,10h               ; adjust for offset
  37.          mov       es,ax                ; and load to ES
  38.          mov       cs:APLCS,es          ; save for posterity
  39.          mov       ds,word ptr es:[80h] ; get arg ptr to DS
  40.          mov       ax,word ptr ds:[10]  ;     SROW  (first locn nbr)
  41.          mov       cs:SROW,ax
  42.          mov       ax,word ptr ds:[12]  ;     SCOL
  43.          mov       cs:SCOL,ax
  44.          mov       ax,word ptr ds:[14]  ;     NROWS
  45.          mov       cs:NROWS,ax
  46.          mov       ax,word ptr ds:[16]  ; get NCOLS (last locn nbr)
  47.          mov       cs:NCOLS,ax
  48.  
  49.          ; remove input item now
  50.          mov       ah,$RELM
  51.          int       SVP
  52.  
  53.          ; calculate result size for APL and space request
  54.          mov       ax,cs:NROWS          ; load NROWS to AX
  55.          mov       cx,cs:NCOLS
  56.          mul       cl                   ; mul by NCOLS, res in AX
  57.          mov       cs:NELEM,ax          ; save ...
  58.          mov       cl,4
  59.          shr       ax,cl                ; div AX by 16 (#pars)
  60.          inc       ax                   ; round up by one
  61.          mov       cs:NPARS,ax          ; save ...
  62.          shl       ax,cl                ; get #bytes rounded up to
  63.          mov       cs:NBYTES,ax         ; mult of 16
  64.  
  65.          ; request space from WS
  66.          push      ds
  67.          mov       dx,NPARS             ; load up nbr pars
  68.          mov       ah,$GETM             ; mem request
  69.          int       SVP                  ; call int .. DS pts to space
  70.  
  71.          ; establish result header
  72.          push      ds                   ; get DS into ES
  73.          pop       es                   ; instead of MOVs
  74.          pop       ds                   ; get DS back
  75.          mov       ax,cs:NBYTES         ; nbr bytes of result
  76.          mov       E$NB,ax              ;
  77.          mov       ax,cs:NELEM          ; nbr elements
  78.          mov       E$NELM,ax            ;
  79.          mov       E$TYPE,3             ; type = char
  80.          mov       E$RANK,2             ; is 2 dim matrix
  81.          mov       ax,cs:NROWS          ; NROWS
  82.          mov       E$DIM1,ax            ;
  83.          mov       ax,cs:NCOLS          ; NCOLS
  84.          mov       E$DIM2,ax            ;
  85.  
  86.          ; finally, tell C what it needs to know
  87.          push      cs:NCOLS
  88.          push      cs:NROWS
  89.          push      cs:SCOL
  90.          push      cs:SROW
  91.          push      es                   ; need to tell C result seg
  92.          mov       ax,12                ; and offset of bufr
  93.          push      ax
  94.  
  95.          ; call C
  96.          call      _rsb
  97.          add       sp,12
  98.  
  99.          ; final housekeeping ...
  100.          mov       ax,es                ; Point result at new object
  101.          mov       ds,ax
  102.          mov       es,cs:APLCS          ; and load to ES
  103.          mov       word ptr es:[80h],ds ; get res ptr to APL
  104.          mov       word ptr es:[82h],0
  105.  
  106.          pop       si
  107.          pop       di
  108.          pop       es
  109.          pop       ds
  110.  
  111.          pop       bp
  112.  
  113.          ret
  114. _main    ENDP
  115.          END
  116.